package com.net.tcp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author Li
 * @Date 2023/4/23 19:23
 */
public class TCPServer {
    public static void main(String[] args) throws IOException {
        System.out.println("tcp,服务端启动");
//        创建服务器端socket
        ServerSocket serverSocket = new ServerSocket(30000);
        System.out.println("等待客服端连接");
//        创建客服端socket通道，阻塞形式
        Socket socket = serverSocket.accept();
        InputStreamReader reader = new InputStreamReader(socket.getInputStream());
        BufferedReader bufferedReader = new BufferedReader(reader);
//        接收上传的消息
        String clientMessage = bufferedReader.readLine();
//        输出信息
        System.out.println("有人说："+clientMessage);
    }
}
